<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserSkillTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_skill', function (Blueprint $table) {
            $table->unsignedBigInteger('user_id')->index();
            $table->unsignedBigInteger('skill_id')->index();
            $table->unsignedInteger('learn_count')->default(0)->comment('学习时长，单位为秒，由课程学习时长记录而来，由观察者来记录');
            $table->unsignedDecimal('complete_percentage')->default(0)->comment('完成百分比，由课程的百分比设置统计记录而来，由观察者来记录');
            $table->primary(['user_id', 'skill_id']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_skill');
    }
}
